from wormbane.language import add_indefinite_article
from wormbane.Thing import Thing


class Monster(Thing):

    def __init__(self):
        Thing.__init__(self)
        self.items = []
        self.time = 0.0
        self.speed = 1.0
        self.race = 'human'
        self.color = 'black'
        self.alive = True
        self.vitality = 1.0
        self.protection = 1.0
        self.damage = 1.0

    @property
    def char(self):
        return self.race[0]

    @property
    def vitality_percentage(self):
        return min(100, max(0, int(round(self.vitality * 100.0))))

    @property
    def vitality_shape(self):
        vitality = self.vitality
        if vitality < 0.2:
            return 'poor'
        elif vitality < 0.5:
            return 'fair'
        else:
            return 'good'

    def __str__(self):
        return add_indefinite_article(self.race)
